<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<jsp:include page="/jsp/common.jsp" />
<jsp:include page="/jsp/tableHead.jsp" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>resource/css/user.css" />
<script type="text/javascript">
$().ready(function(){

	var option = {
			head : [
					{name:"sn",title:"订单信息",width:280},
		            {name:"product_id",title:"收货人",width:80},
		            {name:"amount",title:"订单金额",width:88},
		            {name:"create_date",title:"创建日期",width:97},
		            {name:"create_dat2e",title:"全部状态",width:88},
		            {name:"items.0.order_sn",title:"操作",width:110}
		            ],
            searchURL : "<%=basePath %>user/order_list.do",
            table_Option : {
            	"class" : "QTable_table_03",
				head : {sortable: false, selectAll: {require:false}}
			},
			successFn : function(_result){

				var $table = QTable.get("#listTable").getDOM();
				for(var i=0, len=_result.page.length; i<len; i+=1){

					var data = _result.page[i],
						$row = $("<tr>").addClass("rowHead"),
						$td = $("<td>"),
						$span = $("<span>"),
						$a = $("<a>");
					$span.html("订单编号:").append($a.html(data["sn"]));
					$row.append($td.attr("colspan", 6).append($span));
					$table.append($row);

					var $row = $("<tr>").addClass("rowData"),
						$td1 = $("<td>"),
						$td2 = $("<td>").html(data["contact"]),
						$td3 = $("<td>").html(data["amount"]),
						$td4 = $("<td>").html(data["create_date"]),
						$td5 = $("<td>"),
						$td6 = $("<td>");

					for(var j=0, jLen=data.items.length; j<jLen; j+=1){
						var $a = $("<a>"),
							$img = $("<img>");
						$img.attr("src", data.items[j].product.images[0].url);
						$img.attr("title", data.items[j].product.images[0].title);
						$a.append($img);
						$a.attr("href", "<%=basePath %>user/product_info.do?id=" + data.items[j].product.id);
						$td1.append($a);
					}

					var $div1 = $("<div>"),
						$span1 = $("<span>").html("查看"),
						$span2 = $("<span>").html("|删除"),
						$span3 = $("<div>").html("评价晒单"),
						$span4 = $("<div>").html("退换货"),
						$span5 = $("<a class='btn_again'>").html("还要买").attr("href", "<%=basePath %>user/cartGood_buyAgain.do?orderId=" + data["id"]);
					$div1.append($span1).append($span2);
					$td6.append($div1).append($span3).append($span4).append($span5);

					$row.append($td1).append($td2).append($td3).append($td4).append($td5).append($td6);
					$table.append($row);
				}

				
				//QTable.get("#listTable").refresh(_result);

				//$(".point_total").html(total["remain"]);
			},
            queryFn : function(){
                
				var $table = this.$table,
					$search = this.$search,
					pageSize = 100,
					pageNum = 1;
		
				$search.setPageNum(pageNum);
				$search.setPageSize(pageSize);
				$search.addCondition("create_date", null, null, "DESC");
				$search.doSearch();
    		}
       };
	initTable(option);
});
</script>
</head>
<body>
<jsp:include page="../header.jsp" />
<div class="content">
<div class="bar">
	<jsp:include page="../user/menu.jsp" />
	<div class="div_u_04">
		<div class="top">
			<ul>
				<li>会员等级: 贵宾会员</li>
				<li>账户余额: <strong>￥8602.90元</strong></li>
				<li>消费金额: <strong>￥397.10元</strong></li>
				<li>可用积分: <em>418</em><a href="javascript:;">积分兑换</a></li>
			</ul>
			<ul class="last">
				<li>
					<a href="javascript:;">等待付款(<em>0</em>)</a>
					<a href="javascript:;">等待发货(<em>0</em>)</a>
				</li>
				<li>
					<a href="javascript:;">商品评价(<em>0</em>)</a>
					<a href="javascript:;">到货通知(<em>0</em>)</a>
				</li>
				<li>
					<a href="javascript:;">商品收藏(<em>0</em>)</a>
					<a href="javascript:;">可用优惠券(<em>0</em>)</a>
				</li>
			</ul>
		</div>
		<div class="list border_radius_3">
			<div class="list_title">最新订单</div>
			<table id="listTable">
			</table>
		</div>
	</div>
</div>
</div>
<jsp:include page="../footer.jsp" />
</body>
</html>